<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>

<h1>Categories</h1>
<form method="POST" action=<c:url value="/admin/category/move" />>

 <datalist id="categoriesList">
	 <c:forEach var="cat" items="${categories}" varStatus="status">
	 	<option value="${cat.name}">
	 </c:forEach>
</datalist>
<table>
<c:if test="${categoryNotExists}">
	<tr><td><c:out value="Category with that name doesn't exist!"/></td></tr>
</c:if>

	<tr>
	Move products from category <input type="list" name="fromName" list="categoriesList" autocomplete="off"/>
	to <input type="list" name="toName" list="categoriesList" autocomplete="off"/>
	<input type="submit" value="Move" />
	</tr>
</table>
</form>

<c:if test="${categoryNotEmpty}">
Category not empty!
</c:if>

<table class="search">
  
<c:forEach var="category" items="${categories}" varStatus="status">
    <tr>
    <c:url var="editUrl" value="/admin/category/edit" >
    	<c:param name="categoryId" value="${category.categoryId}" />
    </c:url>
    <c:url var="removeUrl" value="/admin/category/remove" >
 		<c:param name="categoryId" value="${category.categoryId}" />
    </c:url>
   <td><c:out value="${category.name}" /></td>
	<td>
        <a href='<c:out value="${editUrl}"/>'>edit</a>
    </td>
    <td>
        <a href='<c:out value="${removeUrl}"/>'>remove</a>
    </td>
    </tr>
</c:forEach>
</table>

<table>
<tr>
	<td width="70">
		<c:url var="addUrl" value="/admin/category/add" />
		<a href='<c:out value="${addUrl}"/>'>add</a>
	</td>
<%-- 	<td><a href="<c:url value="/admin/category/"/>" >home</a></td> --%>
</tr>
</table>